<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Mocks::Proxy</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Mocks::Proxy</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/mocks/proxy_rb.html">
                vendor/plugins/rspec/lib/spec/mocks/proxy.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000035">add_message_expectation</a>&nbsp;&nbsp;
      <a href="#M000036">add_negative_message_expectation</a>&nbsp;&nbsp;
      <a href="#M000037">add_stub</a>&nbsp;&nbsp;
      <a href="#M000040">has_negative_expectation?</a>&nbsp;&nbsp;
      <a href="#M000041">message_received</a>&nbsp;&nbsp;
      <a href="#M000033">new</a>&nbsp;&nbsp;
      <a href="#M000034">null_object?</a>&nbsp;&nbsp;
      <a href="#M000042">raise_unexpected_message_args_error</a>&nbsp;&nbsp;
      <a href="#M000043">raise_unexpected_message_error</a>&nbsp;&nbsp;
      <a href="#M000039">received_message?</a>&nbsp;&nbsp;
      <a href="#M000038">reset</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">DEFAULT_OPTIONS</td>
          <td>=</td>
          <td class="context-item-value">{         :null_object =&gt; false,       }</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">
          <a href="#M000033" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(target, name, options={})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000033-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 8</span>
 8:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">target</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">options</span>={})
 9:         <span class="ruby-ivar">@target</span> = <span class="ruby-identifier">target</span>
10:         <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span>
11:         <span class="ruby-ivar">@error_generator</span> = <span class="ruby-constant">ErrorGenerator</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">target</span>, <span class="ruby-identifier">name</span>
12:         <span class="ruby-ivar">@expectation_ordering</span> = <span class="ruby-constant">OrderGroup</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@error_generator</span>
13:         <span class="ruby-ivar">@expectations</span> = []
14:         <span class="ruby-ivar">@messages_received</span> = []
15:         <span class="ruby-ivar">@stubs</span> = []
16:         <span class="ruby-ivar">@proxied_methods</span> = []
17:         <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span> <span class="ruby-value">? </span><span class="ruby-constant">DEFAULT_OPTIONS</span>.<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>) <span class="ruby-operator">:</span> <span class="ruby-constant">DEFAULT_OPTIONS</span>
18:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="#M000035" class="method-signature">
          <span class="method-name">add_message_expectation</span><span class="method-args">(expected_from, sym, opts={}, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000035-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 24</span>
24:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_message_expectation</span>(<span class="ruby-identifier">expected_from</span>, <span class="ruby-identifier">sym</span>, <span class="ruby-identifier">opts</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
25:         <span class="ruby-identifier">__add</span> <span class="ruby-identifier">sym</span>, <span class="ruby-identifier">block</span>
26:         <span class="ruby-ivar">@expectations</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">MessageExpectation</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@error_generator</span>, <span class="ruby-ivar">@expectation_ordering</span>, <span class="ruby-identifier">expected_from</span>, <span class="ruby-identifier">sym</span>, <span class="ruby-identifier">block_given?</span> <span class="ruby-value">? </span><span class="ruby-identifier">block</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>, <span class="ruby-value">1</span>, <span class="ruby-identifier">opts</span>)
27:         <span class="ruby-ivar">@expectations</span>.<span class="ruby-identifier">last</span>
28:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">
          <a href="#M000036" class="method-signature">
          <span class="method-name">add_negative_message_expectation</span><span class="method-args">(expected_from, sym, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000036-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 30</span>
30:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_negative_message_expectation</span>(<span class="ruby-identifier">expected_from</span>, <span class="ruby-identifier">sym</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
31:         <span class="ruby-identifier">__add</span> <span class="ruby-identifier">sym</span>, <span class="ruby-identifier">block</span>
32:         <span class="ruby-ivar">@expectations</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">NegativeMessageExpectation</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@error_generator</span>, <span class="ruby-ivar">@expectation_ordering</span>, <span class="ruby-identifier">expected_from</span>, <span class="ruby-identifier">sym</span>, <span class="ruby-identifier">block_given?</span> <span class="ruby-value">? </span><span class="ruby-identifier">block</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>)
33:         <span class="ruby-ivar">@expectations</span>.<span class="ruby-identifier">last</span>
34:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">
          <a href="#M000037" class="method-signature">
          <span class="method-name">add_stub</span><span class="method-args">(expected_from, sym)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000037-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 36</span>
36:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_stub</span>(<span class="ruby-identifier">expected_from</span>, <span class="ruby-identifier">sym</span>)
37:         <span class="ruby-identifier">__add</span> <span class="ruby-identifier">sym</span>, <span class="ruby-keyword kw">nil</span>
38:         <span class="ruby-ivar">@stubs</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-constant">MethodStub</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@error_generator</span>, <span class="ruby-ivar">@expectation_ordering</span>, <span class="ruby-identifier">expected_from</span>, <span class="ruby-identifier">sym</span>, <span class="ruby-keyword kw">nil</span>)
39:         <span class="ruby-ivar">@stubs</span>.<span class="ruby-identifier">first</span>
40:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="#M000040" class="method-signature">
          <span class="method-name">has_negative_expectation?</span><span class="method-args">(sym)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000040-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 62</span>
62:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_negative_expectation?</span>(<span class="ruby-identifier">sym</span>)
63:         <span class="ruby-ivar">@expectations</span>.<span class="ruby-identifier">detect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">expectation</span><span class="ruby-operator">|</span> <span class="ruby-identifier">expectation</span>.<span class="ruby-identifier">negative_expectation_for?</span>(<span class="ruby-identifier">sym</span>)}
64:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000041" class="method-detail">
        <a name="M000041"></a>

        <div class="method-heading">
          <a href="#M000041" class="method-signature">
          <span class="method-name">message_received</span><span class="method-args">(sym, *args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000041-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 66</span>
66:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">message_received</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
67:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">expectation</span> = <span class="ruby-identifier">find_matching_expectation</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
68:           <span class="ruby-identifier">expectation</span>.<span class="ruby-identifier">invoke</span>(<span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>)
69:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">stub</span> = <span class="ruby-identifier">find_matching_method_stub</span>(<span class="ruby-identifier">sym</span>)
70:           <span class="ruby-identifier">stub</span>.<span class="ruby-identifier">invoke</span>([], <span class="ruby-identifier">block</span>)
71:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">expectation</span> = <span class="ruby-identifier">find_almost_matching_expectation</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
72:           <span class="ruby-identifier">raise_unexpected_message_args_error</span>(<span class="ruby-identifier">expectation</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">has_negative_expectation?</span>(<span class="ruby-identifier">sym</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">null_object?</span>
73:         <span class="ruby-keyword kw">else</span>
74:           <span class="ruby-ivar">@target</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:method_missing</span>, <span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
75:         <span class="ruby-keyword kw">end</span>
76:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">
          <a href="#M000034" class="method-signature">
          <span class="method-name">null_object?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000034-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 20</span>
20:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">null_object?</span>
21:         <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:null_object</span>]
22:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000042" class="method-detail">
        <a name="M000042"></a>

        <div class="method-heading">
          <a href="#M000042" class="method-signature">
          <span class="method-name">raise_unexpected_message_args_error</span><span class="method-args">(expectation, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000042-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 78</span>
78:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">raise_unexpected_message_args_error</span>(<span class="ruby-identifier">expectation</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
79:         <span class="ruby-ivar">@error_generator</span>.<span class="ruby-identifier">raise_unexpected_message_args_error</span> <span class="ruby-identifier">expectation</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
80:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000043" class="method-detail">
        <a name="M000043"></a>

        <div class="method-heading">
          <a href="#M000043" class="method-signature">
          <span class="method-name">raise_unexpected_message_error</span><span class="method-args">(sym, *args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000043-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 82</span>
82:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">raise_unexpected_message_error</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
83:         <span class="ruby-ivar">@error_generator</span>.<span class="ruby-identifier">raise_unexpected_message_error</span> <span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
84:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="#M000039" class="method-signature">
          <span class="method-name">received_message?</span><span class="method-args">(sym, *args, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000039-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 57</span>
57:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">received_message?</span>(<span class="ruby-identifier">sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
58:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@messages_received</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">array</span><span class="ruby-operator">|</span> <span class="ruby-identifier">array</span> <span class="ruby-operator">==</span> [<span class="ruby-identifier">sym</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>]}
59:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
60:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="#M000038" class="method-signature">
          <span class="method-name">reset</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000038-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/mocks/proxy.rb, line 50</span>
50:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
51:         <span class="ruby-identifier">clear_expectations</span>
52:         <span class="ruby-identifier">clear_stubs</span>
53:         <span class="ruby-identifier">reset_proxied_methods</span>
54:         <span class="ruby-identifier">clear_proxied_methods</span>
55:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>